package com.ruoyi.api.kehu.order;

import com.ruoyi.system.domain.JiajiaOrderSeparateAccounts;
import com.ruoyi.system.domain.JiajiaUser;
import com.ruoyi.system.domain.vo.JiajiaOrderSeparateAccountsVo;
import com.ruoyi.system.service.ApiSeparateAccountsService;
import com.ruoyi.system.service.IJiajiaUserService;
import com.ruoyi.system.utils.TokenUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

/**
 * 收益信息
 *
 * @author knd
 * @date 2021-10-29
 */
@Controller
@RequestMapping("/api/jiajia/separateAccounts")
public class ApiSeparateAccountsController
{
    private String prefix = "jiajia/separateAccounts";

    @Autowired
    private ApiSeparateAccountsService apiSeparateAccountsService;

    @Resource
    private IJiajiaUserService iJiajiaUserService;

    @RequiresPermissions("jiajia:separateAccounts:view")
    @GetMapping()
    public String version()
    {
        return prefix + "/separateAccounts";
    }

    /**
     * 流水信息
     */
    @PostMapping("/list")
    @ResponseBody
    public List<JiajiaOrderSeparateAccountsVo>  list(JiajiaOrderSeparateAccounts jiajiaOrderSeparateAccounts)
    {
        List<JiajiaOrderSeparateAccountsVo> list = apiSeparateAccountsService.selectJiajiaOrderSeparateAccountsList(jiajiaOrderSeparateAccounts);
        return list;
    }

    /**
     * 收益
     */
    @PostMapping("/sumMoney")
    @ResponseBody
    public BigDecimal sumMoney()
    {

        return apiSeparateAccountsService.sumMoney();
    }

    @PostMapping("/sumMoneyDetail")
    @ResponseBody
    public List<JiajiaOrderSeparateAccountsVo> sumMoneyDetail() {
//        JiajiaUser jiajiaUser = iJiajiaUserService.selectJiajiaUserById(TokenUtil.getUid());
        JiajiaOrderSeparateAccounts jiajiaOrderSeparateAccounts = new JiajiaOrderSeparateAccounts();
        jiajiaOrderSeparateAccounts.setUserId(TokenUtil.getUid());
        return apiSeparateAccountsService.selectJiajiaOrderSeparateAccountsList(jiajiaOrderSeparateAccounts);

    }


}
